
public class BackTrackingProblem {
	
	//Suppose we have 10 stairs, every time you could choose go up 1 stair or 2 stairs 
	//how many results will have.
	
	private static final int STAIRS = 10;
	private static final int MAX_STEPS = 2;
	
	private int resultNumber = 0;
	private int[] steps = new int[STAIRS];
	
	public void doStep(int stairs, int stepNumber){
		if(stairs == 1){
			steps[stepNumber] = 1;
			printResult();
			steps[stepNumber] = 0;
			steps[stepNumber - 1] =0;
			return;
		}
		
		else if(stairs == 0){
			printResult();
			steps[stepNumber-1] = 0;
			return;
		}
		else{
			for(int i = 1; i <=MAX_STEPS; i++){
				if(stairs - i < 0){
					break;
				}
				steps[stepNumber] = i;
				doStep(stairs - i, stepNumber + 1);
			}
		}
		
	}
	
	public void printResult(){
		System.out.println("This is the " + (++resultNumber) + " result: ");
		for(int i = 0; i < STAIRS; i++){
			if(steps[i] == 0){
				break;
			}
			System.out.println(steps[i] + " ");
			
		}
		
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("The program started...");
		BackTrackingProblem bt = new BackTrackingProblem();
		bt.doStep(10, 0);

	}

}
